package com.maysham.tripod.dao;

import com.maysham.tripod.model.BuildTask;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class BuildTaskDao {
    @Resource
    private MongoTemplate template;

    public BuildTask save(BuildTask task){
        return template.save(task);
    }

    public List<BuildTask> fetch() {
        return template.find(Query.query(Criteria.where("status").is(0)), BuildTask.class);
    }
}
